// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store'
import App from './App'
import router from './router'
import axios from 'axios'

Vue.use(ElementUI)
Vue.prototype.axios = axios;

Vue.config.productionTip = false

// // http request 请求拦截器，有token值则配置上token值
axios.interceptors.request.use(
  config => {
    if (localStorage.token) {
      config.headers.token = localStorage.token;
    }
    return config;
  },
  err => {
    return Promise.reject(err);
  });
// http response 服务器响应拦截器，这里拦截401错误，并重新跳入登页重新获取token
// axios.interceptors.response.use(function (response) {
//   // 对响应数据做点什么
//   console.log(response)
//   return response;
// }, function (error) {
//   // 对响应错误做点什么
//   console.log(error)
//   return Promise.reject(error);
// });
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
